unit uCommon;

interface

uses SysUtils, Variants, Classes, Graphics, Dialogs, StdCtrls, StrUtils, Forms;

  procedure MakeFileList(Path,FileExt:string; list: TStrings);

implementation

procedure MakeFileList(Path, FileExt:string; list: TStrings);
var
  sch:TSearchrec;
begin
  if rightStr(trim(Path), 1) <> '\' then
    Path := trim(Path) + '\'
  else
    Path := trim(Path);
  if not DirectoryExists(Path) then
  begin
    exit;
  end;
  if FindFirst(Path + '*', faAnyfile, sch) = 0 then
  begin
    repeat
      Application.ProcessMessages;
      if ((sch.Name = '.') or (sch.Name = '..')) then Continue;
      if DirectoryExists(Path+sch.Name) then
      begin
        MakeFileList(Path+sch.Name,FileExt,list);
      end
      else
      begin
        if (UpperCase(extractfileext(Path+sch.Name)) = UpperCase(FileExt)) or (FileExt='.*') then
        list.Add(Path+sch.Name);
      end;
    until FindNext(sch) <> 0;
    SysUtils.FindClose(sch);
  end;
end;

end.
